package com.letv.core.bean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 频道列表 请求 {@link LetvHttpApi#requestChannels(int, com.letv.http.parse.LetvMainParser, java.lang.String)} 解析
 * {@link ChannelsParser}
 * */
public class ChannelListBean implements LetvBaseBean {

    private static final long serialVersionUID = 1L;
    // key : title， value:频道数组
    private Map<String, List<Channel>> channelMap = new HashMap<String, List<Channel>>();
    // 按获得的数据顺序放入title值,保证顺序不乱
    private List<String> titleList = new ArrayList<String>();

    public Map<String, List<Channel>> getChannelMap() {
        return channelMap;
    }

    public void setChannelMap(Map<String, List<Channel>> channelMap) {
        this.channelMap = channelMap;
    }

    public List<String> getTitleList() {
        return titleList;
    }

    public void setTitleList(List<String> titleList) {
        this.titleList = titleList;
    }

    /**
     * 获取所有数据
     * 
     * @return
     */
    public ArrayList<Channel> getChannelList() {
        ArrayList<Channel> list = new ArrayList<ChannelListBean.Channel>();
        Set<String> keys = channelMap.keySet();
        for (String key : keys) {
            list.addAll(channelMap.get(key));
        }
        return list;
    }

    /**
     * 获取频道ID与频道对象对应集合
     * 
     * @return
     */
    public HashMap<String, Channel> getChannelItemMap() {
        HashMap<String, Channel> map = new HashMap<String, Channel>();
        Set<String> keys = channelMap.keySet();
        List<Channel> list = null;
        for (String key : keys) {
            list = channelMap.get(key);
            for (Channel channel : list) {
                map.put(String.valueOf(channel.getId()), channel);
            }
        }
        return map;
    }

    /**
     * 频道对象
     * */
    public static class Channel implements LetvBaseBean {

        /**
		 * 
		 */
        private static final long serialVersionUID = 1L;

        public Channel() {

        }

        public Channel(int id, String name, String icon, String iconSelected, int type, String subtitle) {
            super();
            this.id = id;
            this.name = name;
            this.icon = icon;
            this.iconSelected = iconSelected;
            this.type = type;
            this.subtitle = subtitle;
        }

        public static final int FROM_HOME_PAGE_MORE = 1;// 从首页更多跳转
        public static final int FROM_CHANNEL_PAGE_ITEM = 2;// 从频道页跳转
        public static final int FROM_MY_PAGE_MORE = 3;// 从我的跳转
        /**
         * 专辑
         */
        public static final int CHANNEL_TYPE_ALBUMS = 1;
        /**
         * 视频
         */
        public static final int CHANNEL_TYPE_VIDEOS = 2;
        /**
         * 精品推荐
         */
        public static final int CHANNEL_TYPE_RECOMM = 3;

        /**
         * 从那里跳进来
         */
        private int fromWhere = FROM_CHANNEL_PAGE_ITEM;
        /**
         * 频道ID
         * */
        private int id;
        // /**
        // * 媒资频道ID
        // */
        // private int mzcid;

        /**
         * 频道名
         * */
        private String name;

        /**
         * 频道图片
         * */
        private String icon;

        /**
         * 频道墙小图标选中
         */
        private String iconSelected;
        /**
         * 频道类型
         * */
        private int type;

        /**
         * 频道看点
         * */
        private String subtitle;

        private String htmlUrl;

        private ArrayList<SiftKVP> mSiftKvps;

        /**
         * 不同频道的页面ID
         */
        private String pageid;

        public String getPageid() {
            return pageid;
        }

        public void setPageid(String pageid) {
            this.pageid = pageid;
        }

        public void setChannelIdInfo(ArrayList<SiftKVP> mSiftKvps) {
            this.mSiftKvps = mSiftKvps;
        }

        public ArrayList<SiftKVP> getChannelIdInfo() {
            return mSiftKvps;
        }

        /**
         * @return the htmlUrl
         */
        public String getHtmlUrl() {
            return htmlUrl;
        }

        /**
         * @param htmlUrl
         * the htmlUrl to set
         */
        public void setHtmlUrl(String htmlUrl) {
            this.htmlUrl = htmlUrl;
        }

        public String getSubtitle() {
            return subtitle;
        }

        public void setSubtitle(String subtitle) {
            this.subtitle = subtitle;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getIcon() {
            return icon;
        }

        public void setIcon(String icon) {
            this.icon = icon;
        }

        public void setSelectedIcon(String icon) {
            this.iconSelected = icon;
        }

        public String getIconSelected() {
            return iconSelected;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        /**
         * @return the fromWhere
         */
        public int getFromWhere() {
            return fromWhere;
        }

        /**
         * @param fromWhere
         * the fromWhere to set
         */
        public void setFromWhere(int fromWhere) {
            this.fromWhere = fromWhere;
        }

        @Override
        public String toString() {
            return "Channel{" + "fromWhere=" + fromWhere + ", id=" + id + ", name='" + name + '\'' + ", icon='" + icon
                    + '\'' + ", type=" + type + ", subtitle='" + subtitle + '\'' + ", htmlUrl='" + htmlUrl + '\''
                    + ", mSiftKvps=" + mSiftKvps + ", pageid='" + pageid + '\'' + '}';
        }
    }
}
